home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
By the Book
/
Mac Pascal Primer, 4.0
/
Chap 3, ShowPict ƒ
/
ShowPict.p
next >
Wrap
Text File
|
1990-06-27
|
1KB
|
59 lines
program ShowPICT;
const
BASE_RES_ID = 400;
var
gPictureWindow: WindowPtr;
{--------------------------------> CenterPict <---}
procedure CenterPict (thePicture: PicHandle; var myRect: Rect);
var
windRect, pictureRect: Rect;
begin
windRect := myRect;
pictureRect := thePicture^^.picFrame;
myRect.top := (windRect.bottom - windRect.top - (pictureRect.bottom - pictureRect.top)) div 2 + windRect.top;
myRect.bottom := myRect.top + (pictureRect.bottom - pictureRect.top);
myRect.left := (windRect.right - windRect.left - (pictureRect.right - pictureRect.left)) div 2 + windRect.left;
myRect.right := myRect.left + (pictureRect.right - pictureRect.left);
end;
{--------------------------------> DrawMyPicture <---}
procedure DrawMyPicture (pictureWindow: WindowPtr);
var
myRect: Rect;
thePicture: PicHandle;
begin
myRect := pictureWindow^.portRect;
thePicture := GetPicture(BASE_RES_ID);
CenterPict(thePicture, myRect);
DrawPicture(thePicture, myRect);
end;
{--------------------------------> WindowInit <---}
procedure WindowInit;
begin
gPictureWindow := GetNewWindow(BASE_RES_ID, nil, WindowPtr(-1));
ShowWindow(gPictureWindow);
SetPort(gPictureWindow);
end;
{--------------------------------> ShowPICT <---}
begin
WindowInit;
DrawMyPicture(gPictureWindow);
while (not Button) do
begin
end;
end.